package com.xuan.system.controller;

import com.xuan.common.core.controller.BaseController;
import com.xuan.common.core.domain.R;
import com.xuan.common.core.domain.TableDataInfo;
import com.xuan.common.core.exception.BusinessException;
import com.xuan.system.domain.user.dto.UserQueryDTO;
import com.xuan.system.domain.user.dto.UserStatusDTO;
import com.xuan.system.service.user.UserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/user")
public class UserController extends BaseController {


    @Resource
    private UserService userService;

    @GetMapping("/list")
    public TableDataInfo listUser(UserQueryDTO userQueryDTO) {
        if (userQueryDTO == null) {
            throw new BusinessException("参数为空");
        }
        return userService.listUser(userQueryDTO);
    }


    @PutMapping("/updateStatus")
    public R<Void> updateUserStatus(@RequestBody UserStatusDTO userStatusDto) {
        if (userStatusDto == null) {
            throw new BusinessException("参数为空");
        }
        return toR(userService.updateUserStatus(userStatusDto));
    }
}
